home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
301-325
/
disk_313
/
uucp
/
uucp1.lzh
/
src
/
sendmail
/
parse.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-01-10
|
1KB
|
74 lines
/*
* PARSE.C
*
* (C) Copyright 1989-1990 by Matthew Dillon, All Rights Reserved.
*/
#include <proto/all.h>
#include <stdio.h>
#include <stdlib.h>
/*
* PARSEADDRESS()
*
* Takes an address containing ! @ % : and converts it to a level 3 ! path.
*
* [path]@mach -> mach[!path]
* [path]%mach -> mach[!path]
* patha:pathb -> patha!pathb
* patha:pathb:pathc -> patha!pathb!pathc
*/
ParseAddress(str, buf, len)
char *str;
char *buf;
short len;
{
short i;
short j;
char *base = buf;
char *ParseAddress2();
for (i = j = 0; i < len; ++i) {
if (str[i] == ':') {
buf = ParseAddress2(str + j, buf, i - j);
*buf++ = '!';
j = i + 1;
}
}
buf = ParseAddress2(str + j, buf, i - j);
*buf = 0;
for (i = 0; base[i] && base[i] != '!'; ++i);
return((int)i);
}
/*
* deals with !, @, and %
*/
char *
ParseAddress2(addr, buf, len)
char *addr;
char *buf;
short len;
{
short i;
for (i = len - 1; i >= 0; --i) {
if (addr[i] == '@' || addr[i] == '%') {
short j = len - i;
strncpy(buf, addr + i + 1, j - 1);
buf += j - 1;
len -= j;
if (len)
*buf++ = '!';
}
}
strncpy(buf, addr, len);
buf += len;
return(buf);
}